package com.share.tool.mock.web;

import com.share.common.common.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@Slf4j
@Api("打印json日志")
@ResponseBody
@RestController
public class JsonLogController {
    @Autowired
    private CoreController coreController;

    @ApiOperation("打印json日志")
    @RequestMapping(value = "/pjl/{code}")
    public Object printJsonLog(@PathVariable("code") String code, HttpServletRequest request) {
        Object result = coreController.httpMork(code, request);
        if (result != null && !(result instanceof Result)) {
            log.info("{}", result);
        }

        return result;
    }
}
